package com.se.io;

import cn.hutool.core.io.IoUtil;
import cn.hutool.core.io.file.FileReader;

import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

import static com.se.io.FileCodeTypeUtil.getFileCodeType;

public class ReadTxtFileHutool {
    public static void main(String[] args) throws IOException {
        String filename = "D:/a.txt";
        //默认UTF-8编码，可以在构造中传入第二个参数做为编码
        FileReader fileReader = new FileReader(filename,getFileCodeType(filename));
        List<String> list = fileReader.readLines();
        List<String> list1 = list.stream()
                .filter(s -> s.contains("1"))
                .collect(Collectors.toList());
//        System.out.printf(list.toString());
        System.out.printf(list1.toString());

    }
}
